<template>
	<div style="display: flex;flex-direction: column;"
		class="otherPage procurementInformation importantAnnouncementInfo">
		<Header :selected="7"></Header>
		<div class="bannerArea">
			<div class="banner" :style="bgImg? 'background:url('+bgImg+') no-repeat;background-size:cover; ':''">
			</div>
		</div>
		<Navigation v-loading="loading" :items="breadcrumbItems" :menus="menus" :checked="1" :bgColor="bgColor">
		</Navigation>
		<div class="content" style="min-height: 600px;">
			<div class="content_bg" style="min-height: 600px;">

				<el-row>
					<el-col class="DetailTitle">
						{{data.now.titles||''}}
					</el-col>
					<el-col class="DetailDate">
						{{$t("releaseDate")}}{{data.now?"："+data.now.publishTime:""}}
					</el-col>
					<el-col class="DetailDescription">
						<div v-html="data.now.content.setWrap()"></div>
					</el-col>
				</el-row>
				<FilesList :files="data.now.fileList"></FilesList>
				<el-row class="pageupOrNext" :gutter="10">
					<el-col :xs="24" :sm="12" :md="12" :lg="12">
						<div v-if="data.previous" @click="goToDetail(data.previous.id)"
							class="newsOtherTitle textAlignLeft">
							{{data.previous.titles?$t('previousArticle'):''}}{{data.previous.titles||''}}

						</div>
						<div v-else class="noOtherTitle textAlignLeft">{{$t('previousArticle')}}{{$t('noMoreTitle')}}
						</div>
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12">
						<div v-if="data.next" @click="goToDetail(data.next.id)" class="newsOtherTitle textAlignRight">
							{{data.next.titles?$t('nextArticle'):''}}{{data.next.titles||''}}
						</div>
						<div v-else class="noOtherTitle textAlignRight">{{$t('nextArticle')}}{{$t('noMoreTitle')}}</div>

					</el-col>
				</el-row>
			</div>
		</div>
		<Footer></Footer>
	</div>
</template>

<script>
	import Header from '../../components/common/header/Header.vue'
	import Navigation from '../../components/common/navigation/Navigation.vue'
	import Footer from '../../components/common/footer/Footer.vue'
	import FilesList from '../../components/common/FilesList.vue'
	import {
		fmtDate
	} from '../../utils/tools'
	import {
		procurementInformationMenu
	} from '../../utils/menu.js'
	// 导入您需要的模块
	import Swiper from "swiper";
	export default {
		components: {
			Header,
			Navigation,
			Footer,
			fmtDate,
			FilesList
		},
		data() {
			return {
				loading: true,
				bgImg: '', //头部banner，默认值已绑定，有背景自动切换
				bgColor: "white", //white/red
				menus: procurementInformationMenu,
				breadcrumbItems: [{
						label: this.$t('home'),
						to: '/'
					},
					{
						label: this.$t('procurementInformation'),
						to: '/procurementInformation'
					},
					{
						label: this.$t('importantAnnouncement'),
						to: '/importantAnnouncement'
					}
				],
				hoverIndex: -1,
				data: {
					now: {
						titles: '',
						eventTime: '',
						content: '',
						publishTime: ''
					}
				},
				pageSize: 10,
				total: 10,
				currentPage: 1,
				id: ''

			};
		},
		computed: {},
		created() {},
		mounted() {

			this.id = this.$route.query.id;
			this.initPage();
			this.bindBg();
			this.bindList().then(i => {
				this.$request.autoTable();
				this.$request.setImageMaxwidth("img");
			});
		},
		methods: {
			handleCurrentChange(currentPage) {
				// console.log(currentPage, 'currentPage');
				this.currentPage = currentPage;
				this.bindList();
			},
			/**
			 * http://127.0.0.1:9999/openApi/purchase/getImportantNoticeDetail
			 *  
			 * 获取重要公告详情
			 */
			bindList() {

				return new Promise((resolve, reject) => {
					let params = {
						importantNoticeId: this.id,
					};
					let that = this;
					that.$request.getImportantNoticeDetail(params).then(res => {
						this.data = res.data;
						this.loading = false;
						resolve();
					}).catch((error) => {
						console.log(error);
					});
				});
			},

			/**
			 *  
			 * (1)	获取重要公告顶部背景
			 *  
			 */
			bindBg() {
				let params = {};
				let that = this;
				that.$request.getImportantNoticeTopImage(params).then(res => {
					that.bgImg = res.data.fileUrl
				}).catch((error) => {
					console.log(error);
				});

			},
			formatDate(date, format) {
				// 自定义日期格式化方法
				// 可以使用moment.js或其他日期处理库来进行格式化
				return fmtDate(new Date(date), format);
			},

			initPage() {

			},
			gotoNewList() {
				this.$router.push({
					name: "党建新闻列表"
				});
			},
			goToDetail(id) {
				this.bindDetail(id).then(i => {
					this.$request.autoTable();
					this.$request.setImageMaxwidth("img");
				})
			},

			bindDetail(id) {
				this.id = id;
				return new Promise((resolve, reject) => {
					let params = {
						importantNoticeId: id,
					};
					let that = this;
					that.$request.getImportantNoticeDetail(params).then(res => {
						this.data = res.data;
						this.loading = false;
						resolve();
					}).catch((error) => {
						console.log(error);
					});
				});
			}

		}
	}
</script>

<style scoped>
	@import url("../../components/common/css/procurementInformation/procurementInformation.css");

	.importantAnnouncementInfo .DetailTitle {
		height: max-content;
		line-height: 40px;
		font-size: 20px;
		text-align: center;
		font-weight: 530;
		color: #333333;
	}

	.importantAnnouncementInfo .DetailDate {
		text-align: center;
		height: 40px;
		line-height: 40px;
		font-weight: 400;
		color: #999999;
		line-height: 33px;
	}

	.importantAnnouncementInfo .DetailDescription {
		font-weight: 400;
		color: #666666;
		line-height: 27px;
	}


	/* 上一篇,下一篇样式 */
	.importantAnnouncementInfo .newsOtherTitle {
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		cursor: pointer;
		font-size: 16px;
		text-decoration: underline;
		height: 70px;
		line-height: 100px;
	}

	.importantAnnouncementInfo .noOtherTitle {
		color: #999;
		text-decoration: none;
		opacity: 0.6;
		height: 70px;
		line-height: 100px;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		cursor: pointer;
		font-size: 16px;
	}

	.importantAnnouncementInfo .newsOtherTitle:hover {
		color: #0484D7;
	}

	.importantAnnouncementInfo .newsOtherTitle.textAlignLeft,
	.importantAnnouncementInfo .noOtherTitle.textAlignLeft {
		text-align: left;
		position: absolute;
		left: -40px;
		bottom: 0px;
		width: 30%;
	}

	.importantAnnouncementInfo .newsOtherTitle.textAlignRight,
	.importantAnnouncementInfo .noOtherTitle.textAlignRight {
		text-align: right;
		position: absolute;
		right: -40px;
		bottom: 0px;
		width: 30%;
	}

	/* 上一篇,下一篇样式----End */

	.content_bg {
		margin: 0px auto;
		padding: 50px;

	}

	.importantAnnouncementInfo .pageupOrNext {
		display: flex;
		position: relative;
		height: 70px;
	}

	@media (min-width: 2560px) {
		.content_bg {
			width: calc(2560px * 0.8);
		}
	}

	@media (max-width: 2560px) {
		.content_bg {
			width: calc(2560px * 0.8);
		}
	}

	@media (max-width: 2320px) {
		.content_bg {
			width: calc(2320px * 0.8);
		}
	}

	@media (max-width: 2120px) {
		.content_bg {
			width: calc(2120px * 0.8);
		}
	}

	@media (max-width: 1920px) {
		.content_bg {
			width: calc(1920px * 0.8);
		}

		.companyCultureImgArea {
			width: 60%;
		}

		.companyCultureContent {}

	}

	@media (max-width: 1720px) {


		.content_bg {
			width: calc(1720px * 0.8);
		}
	}

	@media (max-width: 1520px) {
		.content_bg {
			width: calc(1520px * 0.8);
		}
	}

	@media (max-width: 1366px) {
		.content_bg {
			width: calc(1366px * 0.8);
		}
	}

	@media (max-width: 1120px) {
		.content_bg {
			width: 100%
		}
	}

	@media (max-width: 1024px) {}

	@media (max-width: 900px) {}



	@media (max-width: 768px) {

		.importantAnnouncementInfo .noOtherTitle.textAlignLeft,
		.importantAnnouncementInfo .newsOtherTitle.textAlignLeft {
			left: 0px;
		}

		.importantAnnouncementInfo .noOtherTitle.textAlignRight,
		.importantAnnouncementInfo .newsOtherTitle.textAlignRight {
			right: 0px;
		}
	}

	@media(max-width:440px) {

		.importantAnnouncementInfo .pageupOrNext {
			flex-direction: column;
			height: max-content;
		}

		.importantAnnouncementInfo .newsOtherTitle {
			line-height: 70px;
		}
.importantAnnouncementInfo .noOtherTitle.textAlignRight,
		.importantAnnouncementInfo .noOtherTitle.textAlignLeft,
		.importantAnnouncementInfo .newsOtherTitle.textAlignLeft,
		.importantAnnouncementInfo .newsOtherTitle.textAlignRight {
			right: 0px;
			position: unset;
			width: 100%;
			text-align: center;
		}
	}
</style>
